package qnb._common.easyui;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;
/**
 * 树形菜单实体
 * @author huangxin
 * @date 2019/4/1-19:59
 */
/*      id：绑定节点的标识值。
        PID
        text：显示的节点文本。
        checked：该节点是否被选中。
        chilren:子节点
        url:
        code:权限代码

        */
public class Tree implements  Cloneable{
    private Integer id;
    private Integer pid;
    private String text;
    private Boolean checked;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)//不转换为json
    private List<Tree> children;
    private String url;
    private String code;

    public Tree() {
    }

    public Tree(Integer id, String text) {
        this.id = id;
        this.text = text;
    }

    public Tree(Integer id, Integer pid, String text, Boolean checked, List<Tree> children, String url, String code) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.checked = checked;
        this.children = children;
        this.url = url;
        this.code = code;
    }

    public Tree copy(){
        try {
            Tree tree = (Tree) this.clone();
            tree.setChildren(null);
            return tree;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Boolean getChecked() {
        return checked;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    public List<Tree> getChildren() {
        if (this.children == null) {
            children = new ArrayList<>();
        }
        return children;
    }

    public void setChildren(List<Tree> children) {
        this.children = children;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}